wp_delete_attachment unlink

78

foreach ( $attachments as $attachment ) {
  if ( false === wp_delete_attachment( $attachment->ID, true ) ) {
    $file = get_attached_file( $attachment->ID );
    $file = str_replace( "uploads", "upload-assets", $file);
     wp_delete_file( $file );
   }
 }

Comments

Submit
0 Comments